/*****************************************************************************
 
 File:   OTKWorkspaceManager.java
 
 Date          Build     Author        Version    Comments
29-May-12    P-20-54    rkothari          $$1        Created

****************************************************************************/
package com.ptc.otkjavaexamples.ui;

import com.ptc.cipjava.jxthrowable;
import com.ptc.uifc.uifcComponent.uifcComponent;
import com.ptc.uifc.uifcPushButton.uifcPushButton;
import com.ptc.uifc.uifcTab.uifcTab;
import com.ptc.pfc.pfcCommand.*;


public class OTKServerRegistryDialog extends DefaultUICommandActionListener
{	
    public static String OTK_SERVER_DIALOG = "server_registry";
    public static String OTK_CLOSE_BUTTON = "close_pb";
    public static String OTK_SERVER_TABLE = "server_table";
    public static String OTK_WS_TABLE = "workspace_table";	
    
    @Override
	public void OnCommand() throws jxthrowable
    {
	showDialog();
    }
    
    public void showDialog()
    {
	try
	    {
		/*
		 * Create a dialog from resource file and fill deatils of the Server , Workspaces and Cache			  
		 */			
		uifcComponent.CreateDialog(OTK_SERVER_DIALOG,OTK_SERVER_DIALOG);			
		new OTKServerManager().populateServers();
		new OTKCacheManager();
		
		/*
		 * Add Action listeners for Tab and Close PushButton			 
		 */
		uifcTab.TabFind(OTK_SERVER_DIALOG, "server_cache_tab").AddActionListener(new OTKServerCacheTab());			
		uifcPushButton.PushButtonFind(OTK_SERVER_DIALOG, OTK_CLOSE_BUTTON).AddActionListener(new OTKDialogExit());		
		
		
		
		/*
		 * Display and Activate Dialog.
		 * Please note that ActivateDialog() is a BLOCKING call here.
		 * uifcCoponent.ExitDialog() will unblock this
		 */
		uifcComponent.ActivateDialog(OTK_SERVER_DIALOG);	
		uifcComponent.DestroyDialog(OTK_SERVER_DIALOG);
	    } 
	catch (jxthrowable e)
	    {
		e.printStackTrace();
	    }
	
    }
    
}
